﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Admin_Default"
    MasterPageFile="~/Admin/Admin.master" %>

<asp:Content ID="head" runat="server" ContentPlaceHolderID="head">
    <link href="../JavaScript/jquery/Thickbox/thickbox.css" rel="stylesheet" type="text/css" />

    <script src="../JavaScript/jquery/jquery.conter.js" type="text/javascript"></script>

    <script src="../JavaScript/jquery/CurvyCorners/jquery.curvycorners.min.js" type="text/javascript"></script>

    <script src="../JavaScript/jquery/Thickbox/thickbox.js" type="text/javascript"></script>

    <script language="javascript" type="text/javascript">
        tb_pathToImage = "../CSS/adminGlobal.css";
        var src = "<%=GetFirstMenu()%>";
        $(document).ready(function() {
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(onEndRequest);

            $("#<%=navigationMenu.ClientID %>").accordion({ header: "h3" });
            $("#<%=HeadMenu.ClientID%> li:first").addClass("selected");
            $("#<%=HeadMenu.ClientID%> li a").click(function() {
                $("#<%=HeadMenu.ClientID%> li").removeClass("selected");
                $(this).parent().addClass("selected");
            });

            IniLink4Iframe();

            $("#iframeTarget").attr("src", src);
            $("#iframeTarget").load(function() {
                var bHeight = iframeTarget.document.body.scrollHeight;
                var dHeight = iframeTarget.document.documentElement.scrollHeight;
                var height = Math.max(bHeight, dHeight);
                this.height =Math.max(400,height);
                $("#progressbar").hide();
            });
            $("#progressbar div").center();
        });

        function onEndRequest(sender, args) {
            if (args.get_error()) {
                if (confirm("发现错误，确认后重新进入")) {
                    location = "default.aspx";
                } 
            }

            $("#<%=navigationMenu.ClientID %>").accordion("destroy").accordion({ header: "h3" });
            IniLink4Iframe();
        }


        function IniLink4Iframe() {
            $("a[target='iframeTarget']").click(function() {
                $("#progressbar").show();
                iframeTarget.location = $(this).attr("href");
            });
        }
      
    </script>

</asp:Content>
<asp:Content ID="content" ContentPlaceHolderID="Content" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <!--为了保证局ThickBox的位置正确，在这里加入一个Hidden的a，用于触发Thickbox-->
    <a href="#" style="display: none" id="thickBoxProxy"></a>
    <div id="header">
        <asp:SiteMapDataSource ID="adminSiteMapDataSource" runat="server" ShowStartingNode="false"
            StartingNodeUrl="~/admin/default.aspx" />
        <div class="tab">
            <asp:BulletedList ID="HeadMenu" runat="server" DataSourceID="adminSiteMapDataSource"
                OnClick="HeadMenuClick" DisplayMode="LinkButton" DataTextField="Title" DataValueField="Key">
            </asp:BulletedList>
        </div>
    </div>
    <div id="progressbar">
        <div>
        </div>
    </div>
    <!--Main Content-->
    <div id="mainContent">
        <div id="content">
            <div class="ui-widget ui-widget-content ui-corner-all" style="padding: 10px 10px 10px 10px;
                margin: 0px 10px 10px 0px">
                <iframe id="iframeTarget" name="iframeTarget" frameborder="0" width="100%" height="100%">
                </iframe>
            </div>
        </div>
    </div>
    <div id="nav">
        <div class="innertube">
            <asp:UpdatePanel ID="navigationMenu" runat="server">
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="HeadMenu" />
                </Triggers>
                <ContentTemplate>
                    <asp:Repeater ID="repaeter1" runat="server">
                        <ItemTemplate>
                            <h3>
                                <a href="#">
                                    <%#Eval("Title") %>
                                </a>
                            </h3>
                            <div>
                                <asp:Repeater ID="repeater2" runat="server" DataSource='<%#Eval("ChildNodes")%>'>
                                    <ItemTemplate>
                                        <div>
                                            <a href='<%#Eval("Url") %>' target="iframeTarget">
                                                <%#Eval("Title") %></a>
                                        </div>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </div>
                        </ItemTemplate>
                    </asp:Repeater>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </div>
    <!--Footer-->
    <div id="footer">
    </div>
</asp:Content>
